package com.mk.admin.service.impl;

import com.mk.admin.mapper.InHospitalRegisterMapper;
import com.mk.admin.model.ResultDto;
import com.mk.admin.model.entity.InHospitalRegisterEntity;
import com.mk.admin.model.query.InHospitalRegisterQuery;
import com.mk.admin.model.vo.InHospitalRegisterVo;
import com.mk.admin.service.InHospitalRegisterService;
import com.mk.admin.util.JSONCopy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class InHospitalRegisterServiceImpl implements InHospitalRegisterService {
    @Autowired
    private InHospitalRegisterMapper inHospitalRegisterMapper;

    @Override
    public ResultDto select(InHospitalRegisterQuery query) {
        InHospitalRegisterEntity entity = JSONCopy.copy(query, InHospitalRegisterEntity.class);
        return ResultDto.data(inHospitalRegisterMapper.count(entity), inHospitalRegisterMapper.select(entity));
    }

    @Override
    public ResultDto add(InHospitalRegisterVo inHospitalRegisterVo) {
        InHospitalRegisterEntity entity = JSONCopy.copy(inHospitalRegisterVo, InHospitalRegisterEntity.class);
        return ResultDto.data(inHospitalRegisterMapper.insert(entity));
    }

    @Override
    public ResultDto update(InHospitalRegisterVo inHospitalRegisterVo) {
        InHospitalRegisterEntity entity = JSONCopy.copy(inHospitalRegisterVo, InHospitalRegisterEntity.class);
        return ResultDto.data(inHospitalRegisterMapper.updateById(entity));
    }

    @Override
    public ResultDto delete(int id) {
        return ResultDto.data(inHospitalRegisterMapper.deleteById(id));
    }

    @Override
    public ResultDto status(int id) {
        return ResultDto.data(inHospitalRegisterMapper.status(id));
    }
}
